package org.truenewx.tnxjee.core.util;

import java.util.Objects;

public class Holder<T> {

    private T value;

    public Holder(T value) {
        this.value = value;
    }

    public Holder() {
    }

    public T get() {
        return this.value;
    }

    public void set(T value) {
        this.value = value;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Holder<?> holder = (Holder<?>) o;
        return Objects.equals(this.value, holder.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.value);
    }

    @Override
    public String toString() {
        return this.value == null ? null : this.value.toString();
    }

}
